﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="copyright" content=""/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <title>预约-编辑</title>
    <link href="<%=path%>/favicon.ico" rel="shortcut icon">
    <link rel="stylesheet" type="text/css" href="<%=path%>/css/marketing/public.css" />

    
    
    <link href="<%=path%>/hplus/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
	<link href="<%=path%>/hplus/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
	<link href="<%=path%>/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
	<link href="<%=path%>/hplus/css/animate.min.css" rel="stylesheet">
	<link href="<%=path%>/hplus/css/style.min862f.css?v=4.1.0" rel="stylesheet">  
    <link rel="stylesheet" type="text/css" href="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.css">
   	<style>
	   	.x_img_sc{
	   		position:relative;
	   	}
   		.ad_close{
   			position:absolute;
   			right:0;
   			bottom:0;
   			z-index:222;
   			background:#000;
   		}
   	</style>
</head>
<body  class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
    <div class="container-fluid">
        <div class="row">
        	  <div class="col-md-12">
			   <div class="ibox">
			    <div class="ibox-content text-right">
			      <h3>
						<span>
							<button  type="button" class="btn btn-primary" onclick="window.location.href='<%=path%>/api/bm/ui/createActivity1'">重新选择模板</button>
						</span>
					</h3>
			    </div>
			   </div>   
			 </div> 
        
              <div class="col-md-12  white-bg">
		             <div class="col-md-6" id="left_content">
		               <div class="col-md-12 text-center">
		                   <h4 class="font_color">毕业聚餐好去处</h4>
		               </div>
		               <div class="col-md-12" style="height:200px">
		                 <div class="ibox-content" >
		                    <div class="carousel slide" id="carousel1" >
		                        <div class="carousel-inner ">
		                            <div class="item">
		                                <img alt="image" style="height:200px;" class="img-responsive" src="http://scrm.cecook.cn/project/files/upload/8/2/b0801571-f242-4c94-a727-a75b6cbf89d0_.jpg">
		                            </div>
		                            <div class="item">
		                                <img alt="image" style="height:200px;" class="img-responsive" src="//gqianniu.alicdn.com/bao/uploaded/i4//tfscom/i4/TB10rkPGVXXXXXGapXXXXXXXXXX_!!0-item_pic.jpg_320x320q60.jpg">
		                            </div>
		                            <div class="item active">
		                                <img alt="image" style="height:200px;" class="img-responsive" src="//gqianniu.alicdn.com/bao/uploaded/i4//tfscom/i1/TB1kQI3HpXXXXbSXFXXXXXXXXXX_!!0-item_pic.jpg_320x320q60.jpg">
		                            </div>
		                        </div>
		                        <a data-slide="prev" href="#carousel1" class="left carousel-control">
		                            <span class="icon-prev"></span>
		                        </a>
		                        <a data-slide="next" href="#carousel1" class="right carousel-control">
		                            <span class="icon-next"></span>
		                        </a>
		                    </div>
		                </div>
		               </div>
		               <div class="col-md-12" style="margin-top:40px">
					      <form action="get" class="form-horizontal text-left col-md-12">
						      <div class="form-group">
		                         <p class="font_color col-sm-2">店名:</p >
			                     <span id="store_title" class="font_color  col-sm-10"></span>
		                      </div>
		                      
		                      <div class="form-group">
		                         <p class="font_color col-sm-2">地址:</p >
			                     <span id="store_address" class="font_color  col-sm-10"></span>
		                      </div>
		                      
		                      <div class="form-group">
		                         <p class="font_color col-sm-2">电话:</p >
			                     <span id="store_phone" class="font_color  col-sm-10"></span>
		                      </div>
					      </form>
						</div>  
		                <div class="col-md-12 text-center">
		                  <button type="button" class="btn btn-w-m btn-danger button_color">活动须知</button>
		                </div>
		                <br>
		                <div class="col-md-12 text-center" style="margin-top:20px">
		                   ___<span class="font_color">预约聚餐</span>___
		                </div>
		                <div class="col-md-12" style="margin-top:20px">
		                   <form action="get" class="form-horizontal center">
						      <div class="form-group col-md-12" >
						            <div class="col-sm-12 font_color" style="background-color:#FFFBE1;border-radius:5px;padding:15px">  店名:</div>
		                      </div>
		                       <div class="form-group col-md-12" >
						            <div class="col-sm-12 font_color" style="background-color:#FFFBE1;border-radius:5px;padding:15px">  手机号:</div>
		                      </div>
		                       <div class="form-group col-md-12" >
						            <div class="col-sm-12 font_color" style="background-color:#FFFBE1;border-radius:5px;padding:15px">  就餐时间:</div>
		                      </div>
		                       <div class="form-group col-md-12" >
						            <div class="col-sm-12 font_color" style="background-color:#FFFBE1;border-radius:5px;padding:15px">  预计人数:</div>
		                      </div>
		                       <div class="form-group col-md-12" >
						            <div class="col-sm-12 font_color" style="background-color:#FFFBE1;border-radius:5px;padding:15px">  预约店铺:</div>
			                      </div>
		                     
					      </form>
		                </div>
		                
		                <div class="col-md-12 text-center" style="margin-top:20px">
		                                                            请完善信息方便餐厅给你发送乘车路线
		                </div>
		                <div class="col-md-12 text-center" style="margin-top:20px">
		                   <div class="col-sm-3"></div>
		                   <button type="button" class="col-sm-6  btn btn-lg  btn-danger font_color button_color">提交预约</button>
		                   <div class="col-sm-3"></div>
		                </div>
		                
	                    <ul class="col-md-12 s_footer" style="margin-top:80px">
								<li class="col-md-6 text-center"><img src="<%=path%>/images/marketing/icon_wb.png" id="erweima_weixin2" style="width:79px;height:79px;">
									<p>微信二维码</p></li>
								<li class="col-md-6 text-center"><img src="<%=path%>/images/marketing/icon_wb.png" id="erweima_weibo2" style="width:79px;height:79px;">
									<p>微博二维码</p></li>
						</ul>  
		                <div class="col-md-12 text-center">
		                                                           zhfeat提供技术服务
		                </div>
		         </div> 
                     <div class="col-md-6">
                        <div class="row">
                          <form method="post" id="upload_pic" class="form-horizontal m-t text-center" enctype="multipart/form-data">
                             <div class="form-group col-md-12">
                                <label class="col-sm-2" style="margin-top:10px;margin-left:-12px;"><i id="title_name"><b style="color:red">*</b>&nbsp;主题</i></label>
                                <div class="col-sm-9" style="margin-left:-12px;">
                                    <input type="text" class="form-control" id="focusedInput" placeholder="不超过25个字" maxlength="25" onblur="checkLength(this)">
                                </div>
                             </div>
                             <div class="col-md-12 text-left" style="margin-left:10px">风格定义</div>
                             <div class="col-md-12 text-left" style="margin-top:10px">
                                    <div class="radio i-checks text-left">
                                        <label>
                                            <input id="default_design" type="radio" checked="checked" value="option1" name="a"> <i></i> 使用默认模板</label>
                                    </div>
                                    <div class="form-group col-md-12">
	                                    <div class="radio i-checks text-left col-md-1">
	                                        <label>
	                                            <input id="input_design" type="radio" value="option2" name="a"> <i></i></label>
	                                    </div>
	                                    <div class="col-md-11 btn-group k_color_box text-left" style="margin-top:5px;margin-left:-10px">
                                            <div class="k_color col-sm-4 text-left" >
		                                        <label class="checkbox-inline i-checks x_radio_li" style="padding:0; ">背景颜色</label>
		                                        <img src="<%=path%>/images/marketing/ha.png"> <span class="caret" data-toggle="dropdown" style="margin:11px 2px;"></span>
		                                        <input  type="color" id="theme_info_color" type="color" onchange="reloadMuBan()" style="opacity:0;position:absolute;top:0;width:100px;margin-left:-60px">
		                                    </div>
		                                     <div class="k_color col-sm-4 text-left" >
		                                        <label class="checkbox-inline i-checks x_radio_li" style="padding:0; ">文字颜色</label>
		                                        <img src="<%=path%>/images/marketing/ha.png"> <span class="caret" data-toggle="dropdown" style="margin:11px 2px;"></span>
		                                        <input type="color" onchange="reloadMuBan()" id="text_info_color" style="opacity:0;position:absolute;top:0;width:100px;margin-left:-60px">
		                                    </div>
		                                    <div class="k_color col-sm-4 text-left" >
		                                        <label class="checkbox-inline i-checks x_radio_li" style="padding:0; ">按钮颜色</label>
		                                        <img src="<%=path%>/images/marketing/ha.png"> <span class="caret" data-toggle="dropdown" style="margin:11px 2px;"></span>
		                                        <input  type="color" onchange="reloadMuBan()" id="button_css" style="opacity:0;position:absolute;top:0;width:100px;margin-left:-60px">
		                                    </div>
	                                    </div>
	                                    
                                    </div>
                             </div>
                             
                             <div class="form-group col-md-12">
                                <label class="col-sm-2" style="margin-top:10px;margin-left:-12px;"><i id="title_name"><b style="color:red">*</b>&nbsp;主题</i></label>
                                <div class="col-sm-9" style="margin-left:-12px;margin-top:20px">
                                     <div class="col-sm-4">
	                                      <div class="x_pt_h">
	                                          <div class="x_img_sc">
	                                           <img id="img1" src="<%=path%>/images/marketing/img_p.png" style="width:100px; height:100px;">
	                                           <img hidden="" id="close1" class="ad_close" indexNum="1" imageId="img1" src="<%=path%>/images/marketing/ad_close.png"/>  
	                                          </div>
	                                          <input accept="image/gif,image/jpeg,image/x-png" type="file" id="x_inputfile" onchange="uploadPic(1)" name="filepath1"
	                                          style=" filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity: 0.5; opacity: 0.0; position:absolute; z-index:99;width: 100px; height: 100px;margin-top:-100px">
	                                      </div>
	                                      <div class="x_line_h"> 图1</div>
                                     </div>
                                     <div class="col-sm-4">
	                                      <div class="x_pt_h">
	                                          <div class="x_img_sc">
	                                           <img id="img2" src="<%=path%>/images/marketing/img_p.png" style="width:100px; height:100px;">
	                                           <img hidden="" id="close2" class="ad_close" indexNum="2" imageId="img2" src="<%=path%>/images/marketing/ad_close.png"/>  
	                                          </div>
	                                          <input accept="image/gif,image/jpeg,image/x-png" type="file" id="x_inputfile2" onchange="uploadPic(2)" name="filepath2"
	                                          style=" filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity: 0.5; opacity: 0.0; position:absolute; z-index:99;width: 100px; height: 100px;margin-top:-100px">
	                                      </div>
	                                      <div class="x_line_h"> 图2</div>
                                     </div>
                                     <div class="col-sm-4">
	                                      <div class="x_pt_h">
	                                          <div class="x_img_sc">
	                                           <img id="img3" src="<%=path%>/images/marketing/img_p.png" style="width:100px; height:100px;">
	                                           <img hidden="" id="close3" class="ad_close" indexNum="3" imageId="img3" src="<%=path%>/images/marketing/ad_close.png"/>  
	                                          </div>
	                                          <input accept="image/gif,image/jpeg,image/x-png" type="file" id="x_inputfile3" onchange="uploadPic(3)" name="filepath3"
	                                          style=" filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity: 0.5; opacity: 0.0; position:absolute; z-index:99;width: 100px; height: 100px;margin-top:-100px">
	                                      </div>
	                                      <div class="x_line_h"> 图3</div>
                                     </div>
                                     
                                    
                                </div>
                             
                             </div>
                             <div class="form-group text-left">
								<label style="margin-left:30px">
										参与门店
								</label>
								<a style="color: #03a9f4;margin-left:30px" id="bm_cmen" data-toggle="modal" href="<%=path%>/api/bm/ui/store" data-target="#store_modal">
									选择门店
								</a>
						    </div>
						    
						    <div class="panel panel-default  col-sm-11" style="margin-left:15px;">
								<div class="panel-body">
									<ul id="bm_md_list"></ul>
								</div>
						    </div>
						    
						    <div class="x_footer_information  text-left col-md-12">
								<p><b style="color:red">*</b>&nbsp;活动须知</p>
								<textarea id="detail_rule" class="panel panel-default panel-body col-sm-11" maxlength="100" onblur="checkLength(this)"></textarea>
							</div>
						    
						    <div class="x_footer_information  text-left col-md-12">
								<p>短信文本</p>
								<textarea id="sms_content" class="panel panel-default panel-body col-sm-11" maxlength="100" onblur="checkLength(this)"></textarea>
							</div>
						    <p class=" col-md-12 text-left" id="set_button1">页脚信息</p>
						    
                          </form>
                          <div class="row col-md-12" style="margin-left:1px">
	                         <form id='_weixin_qrcode' action="post" class="form-vertical m-t text-left col-md-3" enctype='multipart/form-data'>
                                  <div class="row">
										<div class="x_img_sc">
											<img id="img4" src="<%=path%>/images/marketing/img_p.png" style="width:100px;height:100px;">
										</div>
										<input type="file" accept="image/gif,image/jpeg,image/x-png" id="x_inputfile"   onchange="fileloadon('weixin')" name="weixin_qrcode"
											style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99;width: 100px; height: 100px;margin-top:-100px">
								  </div>
                                  <label class="checkbox-inline i-checks" style="margin-left:-9px"><input id="input_weixin" type="checkbox" value="option1" >微信二维码</label>
                               </form>
	                                    
                               <form  id='_weibo_qrcode' enctype='multipart/form-data' action="post" class="form-vertical m-t text-left col-md-3">
								  <div class="row">
									  <div class="x_img_sc">
										  <img id="img5" src="<%=path%>/images/marketing/img_p.png"  style="width:100px;height:100px;"/>
									  </div>
									  <input type="file" accept="image/gif,image/jpeg,image/x-png" id="x_inputfile" onchange="fileloadon('weibo')" name="weibo_qrcode"
										  style="filter: alpha(opacity = 50); -moz-opacity: 0.5; -khtml-opacity: 0.5; opacity: 0.0; position: absolute; z-index: 99;width: 100px; height: 100px;margin-top:-100px;" />
								  </div>
								  <label class="checkbox-inline i-checks" style="margin-left:-9px"><input id="input_weibo" type="checkbox" value="option1">微博二维码</label>
							   </form>	
                           </div>
                          <div class="row col-md-12" style="margin-left:8px; margin-top:20px;">
	                            <button id="x_button_l" type="button" class="btn btn btn-default col-md-2" onclick="window.location.href='<%=path%>/api/bm/ui/createActivity1'">取消</button>
	                            <button id="x_button_y" type="button" class="btn  btn-warning col-md-2" style="margin-left:5px" onclick="javascript:save();">暂存</button>
	                            <button id="x_button_bm" type="button" class="btn  btn-primary col-md-2" style="margin-left:5px" onclick="javascript:next();">下一步</button>
	                      </div>
                        
                        </div>
                     </div>
              </div>
          </div>
       </div>
    </div>
    
   <div class="modal inmodal fade" id="store_modal" tabindex="-1" role="dialog"  aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
               
            </div>
        </div>
    </div>
    

    <!-- 添加门店 -->
    <!-- 编辑门店 -->
   
	
    <!-- 添加门店 -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
   <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
   	<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
   

   <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.2.2/jquery.form.min.js"></script>

    
    <script src="<%=path%>/hplus/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="<%=path%>/hplus/js/content.min.js?v=1.0.0"></script>
    <script src="<%=path%>/hplus/js/plugins/iCheck/icheck.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.js"></script>
	<script type="text/javascript" src="<%=path%>/js/marketing/dialog.js"></script>
    <script>
	    var activity_id;
	    var type;
	    var model_id="3";
	    var title;
	    var picObj=new Object();
	    var weixin_qrcode="";
	    var weibo_qrcode="";
	    var commit_info;
	    var detail_rule="";
	    
	    var head_pic;
	    var activity_pics;
		var access_token=$.cookie('access_token');
		var cid=$.cookie('cid');
		var uid=$.cookie('uid');
		var key_word;
		var startIndex=0;
		var pageSize=5;
		var store_names=new Array();
		var store_ids=new Array();
		
		var storeeId;
		//标记编辑活动是否保存
		var save_tag=false;
		
		var button_css;
		var theme_info_color;
		var text_info_color;
		
		var defined_style=false;
		var choseQrWeixinFlag=false;
		var choseQrWeiboFlag=false;
		
		var next_flag=false;
		//短信文本
		var sms_content;
		var status="2";
		
		
		
		$('img').error(function(){
		    $(this).attr('src', '<%=path%>/images/img_load_error.png');
		});
		
		
		 $(".x_radio_pic1").click(function () {
			defined_style=false;
			reloadMuBan();
		        
		 });
		 $(".x_radio_pic2").click(function () {
			defined_style=true;
			reloadMuBan();
		 });
	    $(".s_typeCheck  img").click(function () {
	        <%-- var sr = $(this).attr("src");
	        if (sr == "<%=path%>/images/marketing/s_check_no.png") {
	            $(this).attr("src", "<%=path%>/images/marketing/s_check.png");
	        } else {
	            $(this).attr("src", "<%=path%>/images/marketing/s_check_no.png");
	        }
	        console.log("------sssssssssssss----->"); --%>
	    });
	    $(".x_radio_li  img").each(function (i) {
	        var count = $(".x_radio_li  img").length; 
	        $(this).click(function () {
	            var sr0 = $(this).attr("src");
	            if (sr0 == "<%=path%>/images/marketing/img_radio_n.png") {
	                $(this).attr("src", "<%=path%>/images/marketing/img_radio.png");
	            } else {
	                $(this).attr("src", "<%=path%>/images/marketing/img_radio_n.png");
	            }
	            for (m = 0; m < count; m++) {
	                if (m != i)
	                {
	                    $(".x_radio_li  img")[m].src = "<%=path%>/images/marketing/img_radio_n.png";
	                }
	            }
	        });
	    });
	   
	    $(".x_list01").click(function () {
	        $(".x_list_center01").show();
	        $(".x_list_center02").hide();
	
	        $(".x_list01 h3").css({ "color": "#03a9f4", "text-decoration": "underline" });
	        $(".x_list02 h3").css({ "color": "#666666", "text-decoration": "none" });
	    });
	
	    $(".x_list02").click(function () {
	        $(".x_popup_editor").css("display", "none");
	        $(".x_list_center02,.x_popup_add,.issue_add").show();
	        /*首先点选全选的图片，让全选图片变背景*/
	        $(".x_CheckBox_pic").click(function () {
	            var cutsrc = $(".x_CheckBox_pic").attr('src');
	            if (cutsrc == "<%=path%>/images/marketing/s_check_no.png") {
	                $(".x_CheckBox_pic").attr('src', '<%=path%>/images/marketing/s_check.png');
	                $(".ibox-content").find(".x_CheckBox").attr('src', '<%=path%>/images/marketing/s_check.png');
	            } else {
	                $(".x_CheckBox_pic").attr('src', '<%=path%>/images/marketing/s_check_no.png');
	                $(".ibox-content").find(".x_CheckBox").attr('src', '<%=path%>/images/marketing/s_check_no.png');
	            }
	        });
	        var bool = false;
	        $(".ibox-content").find(".x_CheckBox").click(function () {
	            if ($(this).attr("src") == "<%=path%>/images/marketing/s_check_no.png")
	                $(this).attr('src', '<%=path%>/images/marketing/s_check.png');
	            else
	                $(this).attr('src', '<%=path%>/images/marketing/s_check_no.png');
	
	            var rr = $(".ibox-content").find(".x_CheckBox");
	            if (rr != 0) {
	                $(".x_CheckBox_pic").attr('src', '<%=path%>/images/marketing/s_check_no.png');
	            } else {
	                $(".x_CheckBox_pic").attr('src', '<%=path%>/images/marketing/s_check.png');
	            }
	            for (i = 0; i < 3; i++) {
	                if (rr[i].attributes[1].nodeValue == "<%=path%>/images/marketing/s_check_no.png")
	                {
	                    bool = true;
	                    break;
	                }
	            }
	            if (bool == false) {
	                $(".x_CheckBox_pic").attr('src', '<%=path%>/images/marketing/s_check.png');
	            } else {
	                $(".x_CheckBox_pic").attr('src', '<%=path%>/images/marketing/s_check_no.png');
	            }
	        });
	        $('.issue_add > span').click(function () {
	            $('.x_popup_add,.issue_add').hide(); 
	             $(".x_popup_editor,.issue_editor").hide(); 
	        });
	
	        $(".x_button_add").click(function () {
	            $(".x_popup_t,.issue_t").show();
	            $(".x_popup_editor,.issue_editor").hide();
	          /*   $('.issue_add').hide(); */
	        })
	        $(".issue_t span").click(function () {
	            $(".x_popup_t,.issue_t").hide(); 
	           /*  $(".x_popup_editor,.issue_editor").hide();  */
	            /* $('.x_popup_add').hide(); */
	        })
	      
	        $(".x_editor_bj").click(function () {
	           $(".x_popup_editor,.issue_editor").show();
	            $(".x_popup_t,.issue_t").hide();
	            $('.issue_add').hide(); 
	        })
	        $(".issue_editor span").click(function () {
	            $(".x_popup_editor,.issue_editor").hide();
	           /*  $(".x_popup_t,.issue_t").hide();
	            $('.x_popup_add').hide();  */
	        })
	       
	        /*让所有列表中的check背景图跟随全选图的背景*/
	        $("bj").addClass("src", "<%=path%>/images/marketing/s_check.png");
	        $(".x_list_center01").hide();
	        $(".x_list02 h3").css({ "color": "#03a9f4", "text-decoration": "underline" });
	        $(".x_list01 h3").css({ "color": "#666666", "text-decoration": "none" });
	    });

	  
	   
	     
	     
	   
	     //删除图片
	     $(document).on("click", ".ad_close", function() {
	     	console.log();
	     	var imageId="#"+$(this).attr("imageId");
	     	var index=$(this).attr("indexNum");
	     	$(this).hide();
	 		$(imageId).attr("src","<%=path%>/images/marketing/img_p.png");
	 		
	 		console.log("index------->"+index);
	 		switch (index) {
	 		case "1":
	 			picObj.key1=undefined;
	 			break;
	 		case "2":
	 			picObj.key2=undefined;
	 			break;
	 		case "3":
	 			console.log("---------->ss");
	 			picObj.key3=undefined;
	 			break;

	 		default:
	 			break;
	 		}
	     });
	     //打叉移除选择的门店
	        $(document).on('click','.delete_md_detail',function(){
	        	$(this).remove();
	        	var index=$(this).attr("indexNum");
	        	console.log("删除的下标---->"+index);
	        	store_ids.splice(index,1);
	        }); 
	    
	    $(function(){
	    	
	    	$(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green",});

	    	activity_id=getQueryString("activity_id");
	    	type=getQueryString("type");
	    	model_id=getQueryString("model_id");
	    	if(StringEmpty(activity_id)){
	    		getActivityInfo(activity_id);
		    	activityStore();
	    	}
	    	
	    	
	    });
	    
	    function next(){
	    	next_flag=true;
	        save();
	    	
	    }
	    //保存
	    function save(){
	    	title=$("#focusedInput").val();
	    	detail_rule=$("#detail_rule").val();
	    	sms_content=$("#sms_content").val();

			if(!choseQrWeixinFlag){
				console.log("-------2222-->");
				weixin_qrcode="";
			}
				
			if(!choseQrWeiboFlag){
				console.log("-------3333-->");
				weibo_qrcode="";
			}
			
			//判断是默认
				
			//图片 
	    	activity_pics="";
			for(var i in picObj){
				if(picObj[i]!=undefined){
					console.log("---->"+picObj[i]);
					activity_pics=activity_pics+","+picObj[i];
				}
			}
			if(StringEmpty(picObj["key1"])){
				head_pic=picObj["key1"];
			}else if(StringEmpty(picObj["key2"])){
				head_pic=picObj["key2"];
			}else if(StringEmpty(picObj["key3"])){
				head_pic=picObj["key3"];
			}
			
			console.log("head_pic--->"+head_pic);
			if(next_flag){
				if(StringEmpty(activity_pics)&&
						title.length<21&&
						StringEmpty(detail_rule)&&
						StringEmpty(title)&&StringEmpty(store_ids)
						){
					console.log("activity_pics1111------>"+activity_pics);
					activity_pics=activity_pics.replace(",","");
					console.log("activity_pics2222------>"+activity_pics);
					if(type=="edit"&&save_tag){
						editActivity();
					}else if(type=="activity_copy"&&save_tag){
						editActivity();
					}else if(type=="activity"&&save_tag){
						editActivity();
					}else{
						createActivity();
					}
				}else if(!StringEmpty(title)){
					errorDialog("请填写活动主题");
				}else if(title.length>20){
					errorDialog("活动主题不能穿过20个字");
				}else if(!StringEmpty(detail_rule)){
					errorDialog("请填写活动须知");
				}else if(!StringEmpty(activity_pics)){
					errorDialog("请上传活动图片");
				}else if(!StringEmpty(store_ids)){
					errorDialog("请选择门店");
				}
			}else{
				if(StringEmpty(activity_pics))
					activity_pics=activity_pics.replace(",","");
					
				if(type=="edit"&&save_tag){
					editActivity();
				}else if(type=="activity_copy"&&save_tag){
					editActivity();
				}else{
					createActivity();
				}
			}
	    }
	    //获取模板信息
		function getModelInfo(model_id) {
			var url = "<%=path%>/activityDefinedTemplate/ajaxTemplateDetail";
			$.post(url, {
				"access_token" : access_token,
				"cid" : cid,
				"uid" : uid,
				"id" : model_id,
			}, function(data) {
				
				if (data.status == 200) {
				} else {
				}
			});
		}
		//获取活动信息
		function getActivityInfo(activity_id) {
			var url="<%=path%>/activity/detail";
			$.post(url, {
				"access_token" : access_token,
				"cid" : cid,
				"uid" : uid,
				"activity_id" : activity_id,
			}, function(data) {
				
				if (data.status == 200&&data.data!=undefined) {
					
					if(type!="activity_copy"){
						save_tag=true;
					}
					
					setInvitationHtml(data.data);
				} else {
					
				}
			});
		}
			
		//创建活动
		function createActivity(){
			var url = "<%=path%>/activity/create";
			
			console.log("button_css--->"+button_css);
			console.log("activity_pics------>"+activity_pics);
			$.post(url, {
				"access_token" :access_token,
				"cid" : cid,
				"uid" : uid,
				"activity_name" : title,
				"model_id" : "3",
				"weixin_qrcode" : weixin_qrcode,
				"weibo_qrcode" : weibo_qrcode,
				"tag" : "sys_invitation",
				"activity_detail_rule" : detail_rule,
				"activity_pics" : activity_pics,
				"head_pic" : head_pic,
				"theme_info_color" : theme_info_color,
				"button_css" : button_css,
				"text_info_color" : text_info_color,
				"sms_content":sms_content,
				"status":status,
				"coupon_number" : "1000000",
			}, function(data) {
				
				if (data.status == 200) {
					activity_id=data.activity_id;
					save_tag=true;
					
					if(StringEmpty(store_ids)){
						saveActivityStore();
					}else{
						if(next_flag){
			    			window.location.href = "<%=path%>/api/bm/ui/invitation03?activity_id="+activity_id;
			    		}else{
				    			successDialog("保存成功");
			    		}
					}
					
					
				} else {
					errorDialog(data.message);
				}
			});
		}
		//编辑活动
		function editActivity() {
			console.log("weixin--->"+weixin_qrcode);
			console.log("weibo--->"+weibo_qrcode);
			console.log("text_info_color---->"+text_info_color);
			var url = "<%=path%>/activity/editActivity";
			console.log("button_css--->"+button_css);
			console.log("activity_pics------>"+activity_pics);
			$.post(url, {
				"access_token" :access_token,
				"cid" : cid,
				"uid" : uid,
				"activity_name" : title,
				"model_id" : model_id,
				"weixin_qrcode" : weixin_qrcode,
				"weibo_qrcode" : weibo_qrcode,
				"tag" : "sys_inviation",
				"activity_detail_rule" : detail_rule,
				"activity_id" : activity_id,
				"head_pic" : head_pic,
				"theme_info_color" : theme_info_color,
				"button_css" : button_css,
				"text_info_color" : text_info_color,
				"activity_pics" : activity_pics,
				"sms_content":sms_content,
				"status":status,
			}, function(data) {
				
				if (data.status == 200) {
					save_tag=true;
					if(StringEmpty(store_ids)){
						saveActivityStore();
					}else{
						if(next_flag){
			    			window.location.href = "<%=path%>/api/bm/ui/invitation03?activity_id="+activity_id;
			    		}else{
				    			successDialog("保存成功");
			    		}
					}
				} else {
					errorDialog(data.message);
				}
			});
		}
		var tag;
		var flag=false;
		var file_path;
		function uploadPic(upload_type) {
			tag=upload_type;
			file_path="filepath"+upload_type;
	        $("#upload_pic").submit(function () {  
	        	if(flag){
	        		return ;
	        	}
	        	flag=true;
	            $("#upload_pic").ajaxSubmit({
	                type: "post",
	                url: "${pageContext.request.contextPath}/api/uploadfile/file",
	                data:{"typename":file_path},
	                success: function (data1) {
	                	
	                	setImagePic(data1.realSavePath);
	                },
	                error: function (msg) {
	                    errorDialog("文件上传失败");    
	                }
	            });
	            return false;
	        });
	        flag=false;
	        $("#upload_pic").submit();
		}
		
		//设置活动图片
		function setImagePic(pic){
			switch (tag) {
			case 1:
				$("#close1").show();
				$("#img1").attr('src',pic);
				var id1="#pic"+1;
				picObj.key1=pic;
				$(id1).attr('src',pic);
				break;
			case 2:
				$("#close2").show();
				$("#img2").attr('src',pic); 
				var id2="#pic"+2;
				picObj.key2=pic;
				$(id2).attr('src',pic);
				break;
			case 3:
				$("#close3").show();
				var id3="#pic"+3;
				$("#img3").attr('src',pic); 
				picObj.key3=pic;
				$(id3).attr('src',pic);
				break;
			default:
				break;
			}
		}
		//设置信息
		function setInvitationHtml(data){
			status=data.status;
			$("#focusedInput").val(data.name); 
			//设置图片
			if(StringEmpty(data.pic_url)){
				var pics = data.pic_url.split(",");
				var lunbo_html='';
				for(var i=0;i<pics.length;i++){
					var id=parseInt(i)+parseInt(1); 
					var imgId="#img"+id;
					var closeId="#close"+id;
					$(closeId).show();
					$(imgId).attr('src',pics[i]); 
					if(i==0){
						lunbo_html+='<div class="item active center"><img style="height:200px"  alt="image" class="img-responsive text-center" src="'+pics[i]+'"></div>'

					}else{
						lunbo_html+='<div class="item"><img style="height:200px" alt="image" class="img-responsive" src="'+pics[i]+'"></div>'
					}
					
					switch (id) {
					case 1:
						picObj.key1=pics[i];
						break;
					case 2:
						picObj.key2=pics[i];
						break;
					case 3:
						picObj.key3=pics[i];
						break;

					default:
						break;
					}
					
				}
				$(".carousel-inner").html(lunbo_html);
			}
			//活动细则
			if(StringEmpty(data.detail_rule)){
	
				$("#detail_rule").val(data.detail_rule); 
			}
			sms_content=data.bak1;
			console.log("-----sms_content----->"+data.bak1);
			if(StringEmpty(sms_content))
				$("#sms_content").val(sms_content);
			
			
			//设置二维码
			if(StringEmpty(data.weibo_qrcode)){
				choseQrWeiboFlag=true;
				weibo_qrcode=data.weibo_qrcode;
				$('#input_weibo').parent().addClass("checked");
				$("#input_weibo").attr("checked","checked"); 
				document.getElementById('img5').src = data.weibo_qrcode;
				document.getElementById('erweima_weibo2').src = data.weibo_qrcode;
				
			}
			if(StringEmpty(data.weixin_qrcode)){
				weixin_qrcode=data.weixin_qrcode;
				choseQrWeixinFlag=true;
				document.getElementById('img4').src = data.weixin_qrcode;	
				 $('#input_weixin').parent().addClass("checked"); 
				 $("#input_weixin").attr("checked","checked"); 
				document.getElementById('erweima_weixin2').src = data.weixin_qrcode;
			}
		    //判断是否有自定义样式
		    button_css=data.button_css;
		    theme_info_color=data.theme_info_color;
		    text_info_color=data.text_info_color;
		    console.log("text_info_color---->"+text_info_color);
		    if(StringEmpty(button_css)||StringEmpty(theme_info_color)||StringEmpty(text_info_color)){
		    	document.getElementById('theme_info_color').value=theme_info_color;
				document.getElementById('button_css').value=button_css;
				document.getElementById('text_info_color').value=text_info_color;
		    	defined_style=true;
		    	$('#input_design').parent().addClass("checked"); 
				$("#input_design").attr("checked","checked"); 
				$('#default_design').parent().removeClass("checked"); 
				$("#default_design").removeAttr("checked"); 
				
				
		    	reloadMuBan();
		    }
		}
		var flag=false;
		function fileloadon(upload_type) {
		    $("#_weixin_qrcode").submit(function () {  
		    	if(flag){
		    		return ;
		    	}
		    	flag=true;
		        $("#_weixin_qrcode").ajaxSubmit({
		            type: "post",
		            url: "${pageContext.request.contextPath}/api/uploadfile/file",
		            data:{"typename":"weixin_qrcode"},
		            success: function (data1) {
		            	choseQrWeixinFlag=true;
		            	
		            	weixin_qrcode=data1.realSavePath;
		            	$("#img4").attr('src',data1.weixin_qrcode); 
                    	$("#erweima_weixin2").attr('src',data1.weixin_qrcode); 
                    	 $('#input_weixin').parent().addClass("checked"); 
        				 $("#input_weixin").attr("checked","checked"); 
		            },
		            error: function (msg) {
		                errorDialog("文件上传失败");    
		            }
		        });
		        return false;
		    });
		    
		    $("#_weibo_qrcode").submit(function () {  
		    	if(flag){
		    		return ;
		    	}
		    	flag=true;
		        $("#_weibo_qrcode").ajaxSubmit({
		            type: "post",
		            url: "${pageContext.request.contextPath}/api/uploadfile/file",
		            data:{"typename":"weibo_qrcode"},
		            success: function (data1) {
		            	choseQrWeiboFlag=true;
		            	
		            	weibo_qrcode=data1.realSavePath;
		            	$("#img5").attr('src',data1.weibo_qrcode); 
                    	$("#erweima_weibo2").attr('src',data1.weibo_qrcode); 
                    	$('#input_weibo').parent().addClass("checked"); 
        				$("#input_weibo").attr("checked","checked"); 
		            },
		            error: function (msg) {
		                errorDialog("文件上传失败");    
		            }
		        });
		        return false;
		    });
		    switch (upload_type) {
		    
			case "weixin":
				flag=false;
				$("#_weixin_qrcode").submit();
				break;
			case "weibo":
				flag=false;
				$("#_weibo_qrcode").submit();
				break;
		
			default:
				break;
			}
		}
		
		
		 function colseModal(){
	        	$('#store_modal').modal('hide');
	        }
	        
        function determineStore(){
        	store_names.length=0;
        	store_ids.length=0;
        	
        	var cphone="";
        	var caddress="";
        	var name="";
        	$("#bm_cstore .x_CheckBox[src$='s_check.png']").each(
        			function(i, d) {
        				 name = $(this).attr("cname");
        				 cphone=$(this).attr("cname");
        				 caddress=$(this).attr("caddress");
        				store_names[i]=name;
        				store_ids[i]=this.id;
        	});
        	$('#store_title').html(name);
        	$('#store_address').html(caddress);
        	$('#store_phone').html(cphone);
        	
        	var html='';
        	for(var i in store_names){
        		html += '<li id="store_line'+i+'" indexNum="'+i+'" class="delete_md_detail col-md-4 text-left" cid="'+store_names[i]+'" >'+store_names[i]+'<img indexNum="'+i+'" cid="'+store_names[i]+'" id="delete_store" src="<%=path%>/images/marketing/close.png" class="x_lista"></li>';
        	}
        	$('#bm_md_list').html(html);
        	$('#store_modal').modal('hide');
        }
		
		
	      //获取活动门店信息
	    function activityStore(){
	    	var url = "<%=path%>/activityStore/query";
	    	$.post(url,{
	    		"access_token" : access_token,
				"cid" : cid,
				"uid" : uid,
				"activity_id" : activity_id,
	    	},function(data){
	    		
	    		if(data.error_code == "0"){
        			var stores=data.data;
        			var html='';
        	    	for(var i in stores){
        	    		store_ids[i]=stores[i].id;
        	    		store_names[i]=stores[i].name;
        	    		html += '<li id="store_line'+i+'" indexNum="'+i+'" class="delete_md_detail col-md-4 text-left" cid="'+store_names[i]+'" >'+store_names[i]+'<img indexNum="'+i+'" cid="'+store_names[i]+'" id="delete_store" src="<%=path%>/images/marketing/close.png" class="x_lista"></li>';
        	    	}
        	    	$('#bm_md_list').html(html);
        		}else{
        			
        		}
	    	});
	    }
	    
	    //保存用戶选择的门店
	    function saveActivityStore(){
	    	if(StringEmpty(store_ids)){
	    		var storeIds=store_ids.join(",");
		    	var url = "<%=path%>/activityStore/insert";
		    	$.post(url,{
		    		"access_token" : access_token,
					"cid" : cid,
					"uid" : uid,
					"activity_id" : activity_id,
					"store_ids" : storeIds,
		    	},function(data){
		    		
		    		if(next_flag){
		    			window.location.href = "<%=path%>/api/bm/ui/invitation03?activity_id="+activity_id;
		    		}else{
		    			if(data.error_code == "0"){
		    				alert();
			    			successDialog("保存成功");
			    		}else{
			    			errorDialog(data.message);
			    		}
		    		}
		    	});
	    	}else{
	    		
	    	}
	    }
	    
	    
	    
		//获取参数
		function getQueryString(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
			var r = window.location.search.substr(1).match(reg);
			if (r != null)
				return unescape(r[2]);
			return null;
		}

		//判断字符串是否为空
		function StringEmpty(content) {
			console.log("content----->"+content);
			if (content=="undefined"|| content == undefined || content == "" || content == null) {
				console.log("false");
				return false;
			} else {
				console.log("true");
				return true;
			}
		}
		
		
		
		function reloadMuBan() {
			if(defined_style){
				theme_info_color=document.getElementById('theme_info_color').value;
				button_css=document.getElementById('button_css').value;
				text_info_color=document.getElementById('text_info_color').value;
				if(theme_info_color!="#000000")
				$("#left_content").css("background-color",theme_info_color);
				if(button_css!="#000000"&&StringEmpty(button_css)){
					
					$(".button_color").css("background-color",button_css);
					
				}
				console.log("----->text_info_color"+text_info_color);
				if(StringEmpty(text_info_color)&&text_info_color!="#000000"){
					$(".font_color").css("color",text_info_color); 
				}
				
				
			}else{
				/* console.log("ssssssss");
				$(".invitationNav1").css("background-color","");
				$(".DownMenu-order").css("background-color","#FB3753");
				 $(".activity").css("background-color","#FB3753"); 
				$(".invitationNav-eat").css("color","#7b1f09");
				$(".font_color").css("color","#7b1f09");
				$('#activity_deteal').css("color","#ffffff") */
			}
			console.log("-------focusedInput-------->"+$("#focusedInput").val());
			$(".invitationNav-eat").html($("#focusedInput").val());
			$(".shade-som-2").html($("#detail_rule").val());
			
			
		}
		
		 
		
		//监听离开页面
			document.onclick = function (event)

			  {

			  var e = event || window.event;

			  var elem = e.srcElement||e.target;

			          while(elem){   
			              if(elem.id == "menuContent"||elem.id =="more_but") {  
			                      return;
			              }  
			              elem = elem.parentNode;       
			          } 
			          upd();
			      } 
			  
			function upd(){
				  if(StringEmpty(activity_id)){
			    	  unLockActivity();
			      }
			  }
			  function unLockActivity(){
				  var url= "<%=path%>/activity/ajaxUnlockActivity";
		        	$.post(url, {
		        		"access_token" : access_token,
						"cid" : cid,
						"uid" : uid,
						"activityId" : activity_id,
					}, function(data) {
						
					});
		      }
		
    </script>

    </body>
</html>